<template>
  <div>
    <a-list-info
      :infoDatas="infoDatas"
      span="12"
      :haveBarCode="true"
      :BarCode="BarCode"
    />
    <!-- <a-table 
        :columns="columns" 
        :data-source="listdata" 
        :pagination="false"
        bordered></a-table> -->
    <!-- <a-list-table
      :columns="columns"
      :tableData="listdata"
      :isSelecttion="false"
      :loading="false"
      :scroll="{ y: null }"
      :pagination="false"
    >
    </a-list-table> -->
    <table
      class="printTableBorder"
      border="1"
      cellspacing="0"
      cellpadding="0"
    >
      <tr class="tHeader">
        <th
          v-for="item in columns"
          :key="item.key"
          :style="{width:item.width}"
        >{{item.title}}</th>
      </tr>
      <tr
        class="tRow"
        v-for="items in listdata"
        :key="items.pid"
      >
        <td
          v-for="item in columns"
          :key="item.key"
          style="width:500px"
        >{{items[item.dataIndex]}}</td>
      </tr>
    </table>
    <div
      class="nothing printTableBorder"
      v-if="!listdata.length"
    >暂无数据</div>
  </div>
</template>

<script>
import aListTable from '@/views/app/biz/common/aListTable'
import aListInfo from '@/views/app/biz/common/aListInfo'
import {
  getInfoByPid,
  getDetailByConditions,
  getDetailByConditionsCount
} from './saleOrder'

export default {
  props: {
    infoDatas: {
      type: Array
    },
    BarCode: {
      type: String,
      default: null
    },
    // columns: {
    //   type: Array
    // },
    saleOrderPid: {
      type: String,
      default: null
    }
  },
  components: {
    aListTable,
    aListInfo
  },
  data () {
    return {
      listdata: [],
      sData: {
        saleOrderPid: null
      },
      pagination: {
        //分页配置
        current: 1, //当前页码 current
        pageSize: 100000 //每页显示条数 pageSize
      },
      columns: [
        { title: '品名', dataIndex: 'productNameZh', key: 'productNameZh', width: "10%", align: 'center', },
        { title: '通用名', dataIndex: 'commonName', key: 'commonName', width: "10%", align: 'center' },
        { title: '销售单号', dataIndex: 'saleOrderNo', key: 'saleOrderNo', width: "10%", align: 'center', },
        { title: '生产企业名称', dataIndex: 'manufacturerZh', key: 'manufacturerZh', width: "10%", align: 'center', },
        { title: '规格', dataIndex: 'spec', key: 'spec', width: "10%", align: 'center' },
        { title: '型号', dataIndex: 'model', key: 'model', width: "10%", align: 'center' },
        { title: '计量单位', dataIndex: 'measurement', key: 'measurement', width: "10%", align: 'center' },
        { title: '单价(元)', dataIndex: 'iunitprice', key: 'iunitprice', width: "5%", align: 'center', },
        { title: '采购数量', dataIndex: 'num', key: 'num', width: "10%", align: 'center' },
        { title: '金额(元)', dataIndex: 'totalPrice', key: 'totalPrice', width: "5%", align: 'center' },
        { title: '状态', dataIndex: 'saleOrderState', key: 'saleOrderState', width: "10%", align: 'center' },
      ],
    }
  },
  mounted () {
    this.sData.saleOrderPid = this.saleOrderPid
    this.getDetailBypid(this.sData)
  },
  methods: {
    //得到初始化订单商品list
    async getDetailBypid (params) {
      console.log('请求列表时传入的数据', params)
      let listdata = []
      let res = ''
      res = await getDetailByConditions(params, this.pagination)
      console.log(res)
      if (res && res.code && res.code === 'C1' && res.data) {
        const resdata = res.data
        this.orgList = res.data
        for (let item of resdata) {
          listdata.push({
            key: item.pid,
            ...item
          })
        }
        this.listdata = listdata
      } else {
        this.listdata = []
      }
    }
  }
}
</script>

<style>
html {
  height: 99vh;
}
.tHeader {
  min-height: 40px;
  background-color: #eee;
}
.tHeader th {
  text-align: center;
  padding: 5px;
}
.tRow {
  min-height: 30px;
  background-color: #fff;
}
.tRow td {
  text-align: center;
  padding: 5px;
}
.nothing {
  margin-top: 5px;
  height: 100px;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: rgba(234, 240, 241, 0.507);
}
</style>
